import React from 'react';
import DataTable from 'components/DataTable';
import Icon from 'components/Icon';
import Button from 'components/Button';
import { router } from 'dva';
import moment from "moment";
const { Link } = router;

export default (self) => [
  {
    title: 'ID',
    name: 'id',
    formItem: {
      type: 'hidden',
    }
  },{
    title: '名称',
    name: 'name',
    searchItem: {group:'abc'},
    tableItem: {},
    formItem: {
      rules: [
        {
          required: true,
          message: '请填写名称'
        }
      ]
    }
  },{
    title: '校区',
    name: 'campus',
    tableItem: {},
    formItem: {},
  },{
      title: '类别',
      name: 'category',
      tableItem: {},
      formItem: {},
  },{
    title: '创建时间',
    name: 'createTime',
    tableItem: {
      render: text =>
        moment.utc(text).format('YYYY-MM-DD HH:mm')
    },
  },{
    title: '操作',
    tableItem: {
      width: 180,
      render: (text, record) => (
        <DataTable.Oper>
          <Button tooltip="修改" onClick={e => self.onUpdate(record)}>
            <Icon type="edit" />
          </Button>
          <Button tooltip="删除" onClick={e => self.onDelete(record)}>
            <Icon type="trash" />
          </Button>
          <Button tooltip="管理" onClick={e => self.manageClass(record)}>
            <Icon type="gear" />
          </Button>
        </DataTable.Oper>
      )
    }
  }
];

export let createManageClassColumns =  (self, lecturers, students, lessons ) =>[{
  title: '教师',
  name: 'lecturers',
  formItem: {
    type: 'transfer',
    modal: true,
    dataSource: lecturers,
    // normalize: value=> value.map(item=> item.id),
  }
},{
  title: '学生',
  name: 'students',
  formItem: {
    type: 'transfer',
    modal: true,
    dataSource: students,
    // normalize: value=> value.map(item=> item.id),
  },
},{
  title: '课程',
  name: 'lessons',
  formItem: {
    type: 'transfer',
    modal: true,
    dataSource: lessons,
    // normalize: value=> value.map(item=> item.id),
  },
},];
